package com.chengda.dashboard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chengda.dashboard.entity.FactoryScreenInfo;
import com.chengda.dashboard.mapper.FactoryScreenInfoMapper;
import com.chengda.dashboard.service.FactoryScreenInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 工厂大屏信息Service实现类
 */
@Service
public class FactoryScreenInfoServiceImpl extends ServiceImpl<FactoryScreenInfoMapper, FactoryScreenInfo> implements FactoryScreenInfoService {

    @Autowired
    private FactoryScreenInfoMapper factoryScreenInfoMapper;

    @Override
    public List<FactoryScreenInfo> getMachineInfoByWorkshop() {
        // 使用自定义SQL查询
        return factoryScreenInfoMapper.selectMachineInfoByCustomSql();
    }

    @Override
    public List<FactoryScreenInfo> getCustomMachineInfoByWorkshop() {
        QueryWrapper<FactoryScreenInfo> queryLastWrapper = new QueryWrapper<>();
        queryLastWrapper.gt("sort",0);
        queryLastWrapper.orderByAsc("sort").orderByAsc("left_time");
        return list(queryLastWrapper);
    }

    @Override
    public String getMaterialName(String machineId, String gbNum) {
        return factoryScreenInfoMapper.selectMaterialName(machineId, gbNum);
    }
}
